home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Keyboard / Key.h < prev    next >
Text File  |  1997-06-28  |  2KB  |  91 lines

  1. // Key.h
  2.  
  3. #ifndef Key_h
  4. #define Key_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9.  
  10. class KCHRCache;
  11.  
  12. class Key
  13.   {
  14.     public:
  15.         enum KeyCode
  16.           {
  17.             returnKey            = 0x24,
  18.             
  19.             tabKey                = 0x30,
  20.             deleteKey            = 0x33,
  21.             escapekey            = 0x35,
  22.             
  23.             clearKey                = 0x47,
  24.             enterKey                = 0x4c,
  25.             
  26.             function5            = 0x60,
  27.             function6            = 0x61,
  28.             function7            = 0x62,
  29.             function3            = 0x63,
  30.             function8            = 0x64,
  31.             function9            = 0x65,
  32.             function11            = 0x67,
  33.             function13            = 0x69,
  34.             function14            = 0x6b,
  35.             function10            = 0x6d,
  36.             function12            = 0x6f,
  37.  
  38.             function15            = 0x71,
  39.             helpKey                = 0x72,
  40.             homeKey                = 0x73,
  41.             pageUpKey            = 0x74,
  42.             forwardDeleteKey    = 0x75,
  43.             function4            = 0x76,
  44.             endKey                = 0x77,
  45.             function2            = 0x78,
  46.             pageDownKey            = 0x79,
  47.             function1            = 0x7a,
  48.             leftArrow            = 0x7b,
  49.             rightArrow            = 0x7c,
  50.             downArrow            = 0x7d,
  51.             upArrow                = 0x7e,
  52.             power                    = 0x7f,
  53.             
  54.             stopKey                = 0x80,
  55.             unknown                = 0x81
  56.           };
  57.     
  58.     private:
  59.         KeyCode code;
  60.         uint8 character;
  61.         
  62.         void Normalize();
  63.         void CheckCharacter();
  64.         void CheckForStop();
  65.  
  66.         static const uint8 functionNumbers[ 0x20 ];
  67.         
  68.     public:
  69.         Key( const EventRecord& );
  70.         
  71.         KeyCode Code() const                        { return code; }
  72.         uint8 Character() const                    { return character; }
  73.  
  74.         bool operator==( Key k ) const
  75.             { return code == k.code && character == k.character; }
  76.         
  77.         bool operator!=( Key k ) const        { return !( *this == k ); }
  78.         
  79.         bool Special() const;
  80.         bool ForTyping() const                    { return !Special(); }
  81.         bool IsFunctionKey() const;
  82.         uint32 FunctionNumber() const;
  83.         
  84.         static KCHRCache *GetKCHRCache();
  85.         
  86.         uint16 WithModifiers( EventModifiers ) const;
  87.         uint16 WithModifiers( EventModifiers, KCHRCache *kchrResource ) const;
  88.   };
  89.  
  90. #endif
  91.